/*
 * bt_uart.h
 *
 *  Created on: 28 Apr 2015
 *      Author: yiqi.pan
 */

#ifndef SRC_BLUETOOTH_H_
#define SRC_BLUETOOTH_H_

enum
{
	BT_MODE_NONE,
	BT_MODE_SPP = 1,
	BT_MODE_GATT
};

enum
{
	BT_S_NONE,
	BT_S_OFF,
	BT_S_UNCONNECT,
	BT_S_CONNECTED
};

#define BT_UART_BAUDRATE          (uint32_t)115200
#define BT_DATA_TO_TRANSFER       48
#define BT_DATA_TO_RECEIVE        48

extern volatile uint8_t received_packet_len;
extern volatile uint8_t new_packet_received;
extern uint8_t RxBuffer[];
extern volatile uint8_t rxpos;

#define RB112

#ifdef RB112
#include "rb112.h"
#define bt_init	rb_bt_init
#define bt_hw_reset rb_bt_hw_reset
#define bt_disconnect rb_bt_disconnect

#endif


extern void dma_channel01_done(void);
/* uart1 interrupt handler */
extern void uart1_rx_interrupt(void);

/* Initialize the bluetooth module and uart*/
void bt_uart_init(void);

/* send data via bluetooth uart */
void bt_uart_send(uint8_t* data, uint8_t datalen);

/* reset bluetooth uart transmit buffer*/
void bt_uart_reset_tx_buffer(void);

/* reset bluetooth uart receive buffer*/
void bt_uart_reset_rx_buffer(void);

/* process the received data */
void bt_worker(void);

void bt_reset_rx_buffer(void);

void bt_manager(void);

uint8_t bt_get_state(void);


#endif /* SRC_BLUETOOTH_H_ */
